home *** CD-ROM | disk | FTP | other *** search
Wrap
package javax.swing.plaf.basic; import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.IllegalComponentStateException; import java.awt.LayoutManager; import java.awt.Rectangle; import java.awt.event.ComponentListener; import java.beans.PropertyChangeListener; import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JInternalFrame; import javax.swing.KeyStroke; import javax.swing.LookAndFeel; import javax.swing.UIManager; import javax.swing.event.InternalFrameListener; import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.InternalFrameUI; import javax.swing.plaf.UIResource; public class BasicInternalFrameUI extends InternalFrameUI { protected JInternalFrame frame; protected MouseInputAdapter borderListener; protected PropertyChangeListener propertyChangeListener; protected LayoutManager internalFrameLayout; protected ComponentListener componentListener; protected MouseInputListener glassPaneDispatcher; protected JComponent northPane; protected JComponent southPane; protected JComponent westPane; protected JComponent eastPane; protected BasicInternalFrameTitlePane titlePane; private static DesktopManager sharedDesktopManager; private boolean componentListenerAdded = false; private Rectangle parentBounds = null; protected KeyStroke openMenuKey; private boolean keyBindingRegistered = false; private boolean keyBindingActive = false; private InternalFrameListener internalFrameListener = null; public BasicInternalFrameUI(JInternalFrame var1) { } // $FF: synthetic method static boolean access$0(BasicInternalFrameUI var0) { return var0.componentListenerAdded; } // $FF: synthetic method static void access$1(BasicInternalFrameUI var0, boolean var1) { var0.componentListenerAdded = var1; } // $FF: synthetic method static Rectangle access$2(BasicInternalFrameUI var0) { return var0.parentBounds; } // $FF: synthetic method static void access$3(BasicInternalFrameUI var0, Rectangle var1) { var0.parentBounds = var1; } // $FF: synthetic method static InternalFrameListener access$4(BasicInternalFrameUI var0) { return var0.internalFrameListener; } protected void activateFrame(JInternalFrame var1) { this.getDesktopManager().activateFrame(var1); } protected void closeFrame(JInternalFrame var1) { this.getDesktopManager().closeFrame(var1); } protected MouseInputAdapter createBorderListener(JInternalFrame var1) { return new BorderListener(this); } protected ComponentListener createComponentListener() { return new ComponentHandler(this); } protected DesktopManager createDesktopManager() { return new DefaultDesktopManager(); } protected JComponent createEastPane(JInternalFrame var1) { return null; } protected MouseInputListener createGlassPaneDispatcher() { return new GlassPaneDispatcher(this); } protected void createInternalFrameListener() { this.internalFrameListener = new BasicInternalFrameListener(this); } protected LayoutManager createLayoutManager() { return new InternalFrameLayout(this); } protected JComponent createNorthPane(JInternalFrame var1) { this.titlePane = new BasicInternalFrameTitlePane(var1); return this.titlePane; } protected PropertyChangeListener createPropertyChangeListener() { return new InternalFramePropertyChangeListener(this); } protected JComponent createSouthPane(JInternalFrame var1) { return null; } public static ComponentUI createUI(JComponent var0) { return new BasicInternalFrameUI((JInternalFrame)var0); } protected JComponent createWestPane(JInternalFrame var1) { return null; } protected void deactivateFrame(JInternalFrame var1) { this.getDesktopManager().deactivateFrame(var1); } protected void deiconifyFrame(JInternalFrame var1) { this.getDesktopManager().deiconifyFrame(var1); } protected void deinstallMouseHandlers(JComponent var1) { ((Component)var1).removeMouseListener(this.borderListener); ((Component)var1).removeMouseMotionListener(this.borderListener); } protected DesktopManager getDesktopManager() { if (this.frame.getDesktopPane() != null && this.frame.getDesktopPane().getDesktopManager() != null) { return this.frame.getDesktopPane().getDesktopManager(); } else { if (sharedDesktopManager == null) { sharedDesktopManager = this.createDesktopManager(); } return sharedDesktopManager; } } public JComponent getEastPane() { return this.eastPane; } private InternalFrameListener getInternalFrameListener() { return this.internalFrameListener; } public Dimension getMaximumSize(JComponent var1) { return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); } public Dimension getMinimumSize(JComponent var1) { return this.frame == var1 ? this.frame.getLayout().minimumLayoutSize(var1) : new Dimension(0, 0); } public JComponent getNorthPane() { return this.northPane; } public Dimension getPreferredSize(JComponent var1) { return this.frame == var1 ? this.frame.getLayout().preferredLayoutSize(var1) : new Dimension(100, 100); } public JComponent getSouthPane() { return this.southPane; } public JComponent getWestPane() { return this.westPane; } protected void iconifyFrame(JInternalFrame var1) { this.getDesktopManager().iconifyFrame(var1); } protected void installComponents() { } protected void installDefaults() { Icon var1 = this.frame.getFrameIcon(); if (var1 == null || var1 instanceof UIResource) { this.frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon")); } LookAndFeel.installBorder(this.frame, "InternalFrame.border"); } protected void installKeyboardActions() { if (this.internalFrameListener == null) { this.createInternalFrameListener(); } this.openMenuKey = KeyStroke.getKeyStroke(32, 2); this.frame.addInternalFrameListener(this.internalFrameListener); } protected void installListeners() { this.borderListener = this.createBorderListener(this.frame); this.propertyChangeListener = this.createPropertyChangeListener(); this.frame.addPropertyChangeListener(this.propertyChangeListener); this.frame.setLayout(this.internalFrameLayout = this.createLayoutManager()); this.installMouseHandlers(this.frame); this.glassPaneDispatcher = this.createGlassPaneDispatcher(); this.frame.getGlassPane().addMouseListener(this.glassPaneDispatcher); this.frame.getGlassPane().addMouseMotionListener(this.glassPaneDispatcher); this.componentListener = this.createComponentListener(); } protected void installMouseHandlers(JComponent var1) { ((Component)var1).addMouseListener(this.borderListener); ((Component)var1).addMouseMotionListener(this.borderListener); } public void installUI(JComponent var1) { this.frame = (JInternalFrame)var1; this.frame.add(this.frame.getRootPane(), "Center"); this.installDefaults(); this.installComponents(); this.installListeners(); this.installKeyboardActions(); this.setNorthPane(this.createNorthPane(this.frame)); this.setSouthPane(this.createSouthPane(this.frame)); this.setEastPane(this.createEastPane(this.frame)); this.setWestPane(this.createWestPane(this.frame)); this.frame.setOpaque(true); int var2 = this.getNorthPane().getMinimumSize().height + this.frame.getInsets().top + this.frame.getInsets().bottom; this.frame.setMinimumSize(new Dimension(120, var2)); } public final boolean isKeyBindingActive() { return this.keyBindingActive; } protected final boolean isKeyBindingRegistered() { return this.keyBindingRegistered; } protected void maximizeFrame(JInternalFrame var1) { this.getDesktopManager().maximizeFrame(var1); } protected void minimizeFrame(JInternalFrame var1) { this.getDesktopManager().minimizeFrame(var1); } protected void replacePane(JComponent var1, JComponent var2) { if (var1 != null) { this.deinstallMouseHandlers(var1); this.frame.remove(var1); } if (var2 != null) { this.frame.add(var2); this.installMouseHandlers(var2); } } public void setEastPane(JComponent var1) { this.eastPane = var1; } protected final void setKeyBindingActive(boolean var1) { this.keyBindingActive = var1; } protected final void setKeyBindingRegistered(boolean var1) { this.keyBindingRegistered = var1; } public void setNorthPane(JComponent var1) { this.replacePane(this.northPane, var1); this.northPane = var1; } public void setSouthPane(JComponent var1) { this.southPane = var1; } public void setWestPane(JComponent var1) { this.westPane = var1; } protected void setupMenuCloseKey() { } protected void setupMenuOpenKey() { this.frame.registerKeyboardAction(new 1(this), this.openMenuKey, 2); this.frame.getDesktopIcon().registerKeyboardAction(new 2(this), this.openMenuKey, 2); } protected void uninstallComponents() { } protected void uninstallDefaults() { Icon var1 = this.frame.getFrameIcon(); if (var1 instanceof UIResource) { this.frame.setFrameIcon((Icon)null); } LookAndFeel.uninstallBorder(this.frame); } protected void uninstallKeyboardActions() { if (this.internalFrameListener != null) { this.frame.removeInternalFrameListener(this.internalFrameListener); } if (this.isKeyBindingRegistered()) { this.frame.unregisterKeyboardAction(this.openMenuKey); this.frame.getDesktopIcon().unregisterKeyboardAction(this.openMenuKey); } } protected void uninstallListeners() { this.deinstallMouseHandlers(this.frame); this.frame.removePropertyChangeListener(this.propertyChangeListener); this.frame.setLayout((LayoutManager)null); this.internalFrameLayout = null; this.propertyChangeListener = null; this.frame.getGlassPane().removeMouseListener(this.glassPaneDispatcher); this.frame.getGlassPane().removeMouseMotionListener(this.glassPaneDispatcher); if (this.frame.getDesktopPane() != null && this.componentListenerAdded) { this.frame.getDesktopPane().removeComponentListener(this.componentListener); } this.glassPaneDispatcher = null; this.componentListener = null; this.borderListener = null; } public void uninstallUI(JComponent var1) { if (var1 != this.frame) { throw new IllegalComponentStateException(String.valueOf(this) + " was asked to deinstall() " + var1 + " when it only knows about " + this.frame + "."); } else { this.uninstallDefaults(); this.uninstallComponents(); this.frame.setCursor(Cursor.getPredefinedCursor(0)); this.setNorthPane((JComponent)null); this.setSouthPane((JComponent)null); this.setEastPane((JComponent)null); this.setWestPane((JComponent)null); this.uninstallListeners(); this.uninstallKeyboardActions(); this.frame.remove(this.frame.getRootPane()); this.frame = null; } } }